package com.rui.patterns.state.before;

/**
 * @author : [锐神NO.3]
 * @version : [v1.0]
 * @className : Lift
 * @createTime : [2022/2/24 14:43]
 * @description : [描述该类的功能]
 */

public class Lift implements ILift{

    /**
     * 声明一个记录当前电梯状态的变量
     */
    private int state;

    @Override
    public void setState(int state) {
        this.state = state;
    }

    @Override
    public void open() {
        switch(state){
            case OPENING_STATE:
                break;
            case CLOSING_STATE:
                System.out.println("电梯打开了...");
                setState(OPENING_STATE);
                break;
            case RUNNING_STATE:
                break;
            case STOPPING_STATE:
                System.out.println("电梯打开了...");
                setState(OPENING_STATE);
                break;
            default:
                break;
        }
    }

    @Override
    public void close() {
        switch(state){
            case OPENING_STATE:
                break;
            case CLOSING_STATE:
                System.out.println("电梯打开了...");
                setState(OPENING_STATE);
                break;
            case RUNNING_STATE:
                break;
            case STOPPING_STATE:
                System.out.println("电梯打开了...");
                setState(OPENING_STATE);
                break;
            default:
                break;
        }
    }

    @Override
    public void run() {
        switch(state){
            case OPENING_STATE:
                break;
            case CLOSING_STATE:
                System.out.println("电梯打开了...");
                setState(OPENING_STATE);
                break;
            case RUNNING_STATE:
                break;
            case STOPPING_STATE:
                System.out.println("电梯打开了...");
                setState(OPENING_STATE);
                break;
            default:
                break;
        }
    }

    @Override
    public void stop() {
        switch(state){
            case OPENING_STATE:
                break;
            case CLOSING_STATE:
                System.out.println("电梯打开了...");
                setState(OPENING_STATE);
                break;
            case RUNNING_STATE:
                break;
            case STOPPING_STATE:
                System.out.println("电梯打开了...");
                setState(OPENING_STATE);
                break;
            default:
                break;
        }
    }
}
